@extends('wap.layout.base')
@section('scripts')
    <script>
        let app = new Vue({
            el: '#app',
            data: function() {
                return {
                    title: '绑定账号',
                    form: {
                        type : "{{ $three['type'] }}",
                        name : "{{ $three['name'] }}",
                        avatar : "{{ urlencode($three['avatar']) }}",
                        three_id : "{{ $three['idstr'] }}",
                        _token:"{{csrf_token()}}"
                    },
                }
            },
            methods: {
                onClickLeft() {
                    window.location.href = "{{ route('wap.auth.login') }}";
                },
                register() {
                    $.post("{{ route('wap.auth.three') }}",this.form,function(res){
                        if(res.code){
                            that.$toast(res.msg);
                        }else{
                            window.location.href = "{{ route('wap.auth.register') }}";
                        }
                        return false;
                    });
                },
                login() {
                    $.post("{{ route('wap.auth.three') }}",this.form,function(res){
                        if(res.code){
                            that.$toast(res.msg);
                        }else{
                            window.location.href = "{{ route('wap.auth.login') }}";
                        }
                        return false;
                    });
                },
            }
        });
    </script>
@endsection
@section('content')
    <div class="main auth binding auth login" id="app"  v-cloak>
        <div class="container">
            <div class="row">
                <van-nav-bar
                        :title="title"
                        left-text=""
                        border
                        fixed="true"
                        left-arrow="false"
                        @click-left="onClickLeft">
                    <van-icon name="arrow-left" slot="left"/>
                </van-nav-bar>
                <div class="auth-bg"></div>
                <div class="col-xs-12">
                    <div class="auth-form" style="text-align: left;padding-bottom: 5rem">
                        <div class="ui message red">您正在使用第三方账号 <span>{{ $three['name'] }}</span> 绑定链鸽</div>
                        <div class="ui message info">
                            <span style="margin-right: 15px;">提示: </span>  如果你已有帐号，请选择绑定已有账号进行绑定操作；如果你没有链鸽账号，请选择注册新账号进行绑定操作，
                            绑定链鸽帐号后，即可以在登录页面使用第三方登录方式登录此链鸽帐号。
                        </div>
                        <p class="form-submit">
                            <van-button type="default" @click="login()">绑定已有账号</van-button>
                        </p>
                        <p class="form-submit">
                            <van-button type="default" @click="register()">注册新账号</van-button>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

